const { beijingTime } = require("./timer");

const successMessage = (req, res, msg) => {
	return res.status(200).send({
		state: "success",
		message: `${msg}成功！`,
		data: req.body.root,
		timestamp: beijingTime,
	});
};
const resData = (data, res, msg) => {
	return res.status(200).send({
		state: "success",
		message: `${msg}成功！`,
		data: data,
		timestamp: beijingTime,
	});
};

const failMessage = (req, res, msg) => {
	return res.status(403).send({
		state: "fail！",
		message: msg,
		data: req.body.root,
		timestamp: beijingTime,
	});
};

const errMessage = (req, res, msg) => {
	return res.status(500).send({
		state: "error!!!",
		message: msg,
		data: req.body.root,
		timestamp: beijingTime,
	});
};

exports.successMessage = successMessage;
exports.failMessage = failMessage;
exports.errMessage = errMessage;
exports.resData = resData;
